package com.sc.pattern.balking;

import java.io.IOException;

/**
 * Created  on 2018/1/7.
 *
 * @author sc
 */
public class Waiter  extends Thread{

    private final BalkingData balkingData;

    public Waiter(BalkingData balkingData){
        super("waiter");
        this.balkingData = balkingData;
    }

    @Override
    public void run() {
        for (int i = 0; i < 200; i++) {
            try {
                balkingData.save();
            } catch (IOException e) {
                e.printStackTrace();
            }
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}
